package com.ruoyi.system.controlserver;

/**
 * @author chenjy
 * @date 2024/12/3 13:33
 */
public enum AndroidOrder {
    /**
     * 智慧屏控制指令
     */
    SCREENON("screen", "on"),
    SCREENOFF("screen", "off"),
    OPSON("ops", "on"),
    OPSOFF("ops", "off"),
    RESTART("restart", "restart"),
    SOURCEANDROID("source", "ANDROID"),
    SOURCEPC("source", "PC"),
    SOURCEHDMI1("source", "HDMI1"),
    SOURCEHDMI2("source", "HDMI2"),
    SOURCEHDMI3("source", "HDMI3"),
    SOURCEVGA1("source", "VGA1"),
    SOURCEVGA2("source", "VGA2"),
    MUTEON("mute", "on"),
    MUTEOFF("mute", "off"),
    POWEROFF("power", "off");

    private final String type;
    private final String order;

    AndroidOrder(String type, String order) {
        this.type = type;
        this.order = order;
    }

    static AndroidOrder getAndroidOrder(String order) {
        final String[] split = order.split(":");
        for (AndroidOrder value : AndroidOrder.values()) {
            if (value.getType().equals(split[0]) && value.getOrder().equals(split[1])) {
                return value;
            }
        }
        throw new IllegalArgumentException("非法的指令参数");
    }

    public static AndroidOrder getAndroidOrder(String type, String source) {
        for (AndroidOrder value : AndroidOrder.values()) {
            if (type.equals(value.getType()) && source.equals(value.getOrder())) {
                return value;
            }
        }
        return null;
    }


    public String getType() {
        return type;
    }

    public String getOrder() {
        return order;
    }


}
